﻿using System.Collections.Generic;
using System.Windows.Controls;
using System.Windows.Media;
using uTrade.Common;
using uTrade.Controls;

namespace uTrade.Data
{
    internal class Candle
    {
        internal List<DrawObject> GetDrawingObj(PriceInfo pInfo)
        {
            List<DrawObject> lstDrawObj = new List<DrawObject>();
            DrawObject obj = new DrawObject()
            {
                Type = DrawObjectType.CandleLine,
                Name = pInfo.Name + "_candle",
            };

            obj.Vals = pInfo.GetPrice(PriceConstants.PRICE_OPEN);
            obj.Vals1 = pInfo.GetPrice(PriceConstants.PRICE_CLOSE);
            obj.Vals2 = pInfo.GetPrice(PriceConstants.PRICE_HIGH);
            obj.Vals3 = pInfo.GetPrice(PriceConstants.PRICE_LOW);

            lstDrawObj.Add(obj);

            DrawObject obj2 = new DrawObject()
            {
                Type = DrawObjectType.Line,
                Name = pInfo.Name + "_vol",
                Thickness = 1,
                Color = Colors.Blue
            };
            obj2.Vals = pInfo.GetPrice(PriceConstants.PRICE_OPEN);

            lstDrawObj.Add(obj2);

            return lstDrawObj;
        }

        private void GetTlttleText(PriceInfo pInfo, int iIndex)
        {
            int index = pInfo.PriceList.Count - 1;
            List<TextBlock> lstTxtBlk = new List<TextBlock>();
            string str = pInfo.Symbol + "  ";
            str += pInfo.Name + "  ";
            str += pInfo.PriceList[index].Date.ToString("yyyy-MM-dd") + "  ";
            str += DateService.FormatDayOfWeek(pInfo.PriceList[index].Date) + "  ";
            str += "开" + pInfo.PriceList[index].Open + "  ";
            str += "收" + pInfo.PriceList[index].Close + "  ";
            str += "高" + pInfo.PriceList[index].High + "  ";
            str += "低" + pInfo.PriceList[index].Low + "  ";
            str += "涨" + ((pInfo.PriceList[index].Close - pInfo.PriceList[index].Open) / pInfo.PriceList[index].Open).ToString("P") + "  ";
            //FormattedText txt = new FormattedText(str,
            //    System.Globalization.CultureInfo.CurrentCulture,
            //    FlowDirection.LeftToRight, new Typeface("Verdana"),
            //    12, new SolidColorBrush(Color.FromRgb(64, 64, 64)));
            //dc.DrawText(txt, new Point(ChartStartX, 1));
        }

        private void GetFormatedTittle()
        {
        }
    }
}